//
//  LRInputView.m
//  CPetro
//
//  Created by ggx on 2017/3/9.
//  Copyright © 2017年 高广校. All rights reserved.
//

#import "LRInputView.h"

#import <Masonry.h>
@implementation LRInputView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
- (id)initItemWithFrame:(CGRect)frame andlabelName:(NSDictionary *)paramData{
    if (self = [super initWithFrame:frame]) {
        
        [self addSubview:self.tipName];
        [self.tipName mas_makeConstraints:^(MASConstraintMaker *make) {
            make.leading.equalTo(@8);
            make.top.bottom.equalTo(self);
            make.width.equalTo(@80);//
        }];
        
        if ([paramData valueForKey:@"assistantName"]) {
            self.tipName.text = [NSString stringWithFormat:@"%@:",paramData[@"assistantName"]];
        }
        
        [self addSubview:self.inputLineView];
        [self.inputLineView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.leading.equalTo(@13);
            make.height.equalTo(@1);
            make.bottom.right.equalTo(@0);
        }];
        
        [self addSubview:self.inputText];
        [self.inputText mas_makeConstraints:^(MASConstraintMaker *make) {
            make.leftMargin.equalTo(self.tipName.mas_right).offset(8);//dui'zhe
            make.right.equalTo(self).offset(-8);
            make.bottomMargin.equalTo(@-5);
            make.top.equalTo(self).offset(5);
        }];
        if ([paramData valueForKey:@"assistantAccount"]) {
            self.inputText.text = paramData[@"assistantAccount"];
        }else if ([paramData valueForKey:@"assistantPlaceHolder"]){
            NSString *placeString = paramData[@"assistantPlaceHolder"];
            NSMutableAttributedString *placeholder = [[NSMutableAttributedString alloc]initWithString:placeString];
            [placeholder addAttribute:NSForegroundColorAttributeName
                                value:K_SubmitTitleColor
                                range:NSMakeRange(0, placeString.length)];
            _inputText.attributedPlaceholder = placeholder;
        }else{
            self.inputText.placeholder = @"设置登陆密码";
        }
    }
    return self;
}

-(UILabel *)tipName{
    if (!_tipName) {
        _tipName = [[UILabel alloc]init];
    }
    _tipName.textColor = [UIColor lightGrayColor];
    _tipName.font      = [UIFont systemFontOfSize:13.0];
    return _tipName;
}
-(UITextField *)inputText{
    if (!_inputText) {
        _inputText = [[UITextField alloc]init];
    }

    _inputText.textColor = K_SubmitTitleColor;
    _inputText.font      = [UIFont systemFontOfSize:14.0];
    return _inputText;
}
-(UIView *)inputLineView{
    if (!_inputLineView) {
        _inputLineView = [[UIView alloc]init];
    }
    _inputLineView.backgroundColor = [UIColor groupTableViewBackgroundColor];
    return _inputLineView;
}
@end
